import json
import yaml

def convert_json_to_yaml(input_file, output_file):
    # 读取 JSON 文件
    with open(input_file, 'r', encoding='utf-8') as f:
        data = json.load(f)
    
    # 转换格式
    converted = []
    for item in data:
        converted.append({
            'spec_name': item['directory'],
            'spec_url': item['repository_url'],
            'spec_branch': item['branch']
        })
    
    # 写入 YAML 文件
    with open(output_file, 'w', encoding='utf-8') as f:
        yaml.dump(converted, f, allow_unicode=True, sort_keys=False)
    
    print(f"转换完成，结果已保存到 {output_file}")

# 使用示例
input_json = 'successful_submissions.json'
output_yaml = 'output_specs.yaml'
convert_json_to_yaml(input_json, output_yaml)
